package com.zhongjinkang.rhythm.Utils

import android.content.Context

import android.content.SharedPreferences


class SPHelper private constructor(context: Context) {
    private val sp: SharedPreferences
    private val mEditor: SharedPreferences.Editor
    val currentDataVersion = 2

    init {
        sp = context.getSharedPreferences("SPHelper", Context.MODE_PRIVATE)
        mEditor = sp.edit()
    }

    fun saveToken(token:String){
        mEditor.putString("token",token)
        mEditor.apply()
    }
    fun getToken():String{
      return sp.getString("token","").toString()
    }
    fun removeToken(){
        mEditor.remove("token")
    }




    companion object {
        var instance: SPHelper? = null
            private set

        fun init(context: Context) {
            if (instance == null) {
                synchronized(SPHelper::class.java) {
                    if (instance == null) {
                        instance = SPHelper(context)
                    }
                }
            }
        }
    }
}